from datetime import datetime
# 字符串转datetime
dt=datetime.strptime("2021-12-07 20:40:33","%Y-%m-%d %H:%M:%S")
print(dt)
print(dt.year)
print(dt.month)
print(dt.day)
print(dt.hour)
print(dt.weekday())
# datetime 转字符串
str=datetime.strftime(dt,"%Y/%m/%d %H:%M:%S")
print(str)
